package org.example.user.controller;


import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.example.user.model.AddressDO;
import org.example.user.request.AddressAddReqeust;
import org.example.user.service.AddressService;
import org.example.util.JsonData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 电商-公司收发货地址表 前端控制器
 * </p>
 *
 * @author 神殿骑士
 * @since 2024-04-17
 */
@Api(tags="收货地址模块")
@RestController
@RequestMapping("/api/address/v1")
public class AddressController {

    @Autowired
    private AddressService addressService;

    @GetMapping("/find/{address_id}")
    public AddressDO getDetail(@PathVariable String address_id){
        System.out.println("sucess");
        AddressDO detail = addressService.detail(Long.parseLong(address_id));
        return detail;
    }

    @ApiOperation("新增收货地址")
    @PostMapping("add")
    public JsonData add(@ApiParam("地址对象") @RequestBody AddressAddReqeust addressAddReqeust){

        addressService.add(addressAddReqeust);

        return JsonData.buildSuccess();
    }

}

